/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.net.greenet.logmanage.nn;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 根据条件查询UC接收策略日志
 *
 * @author liangdelin
 */
@WebServlet(name = "QueryPolicyReceiveLog", urlPatterns = {"/log/query_policy_receive_log"})
public class QueryPolicyReceiveLog extends HttpServlet {

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        String id = request.getParameter("id");    // 设备
        System.out.println("id" + id);
        String startTime = request.getParameter("startTime");
        System.out.println("startTime" + startTime);
        String endTime = request.getParameter("endTime");
        System.out.println("endTime" + endTime);
        String MessageType = request.getParameter("MessageType");     //optional
        System.out.println("MessageType" + MessageType);
        String MessageNo = request.getParameter("MessageNo");     //optional
        System.out.println("MessageNo" + MessageNo);
        String iDisplayStart = request.getParameter("iDisplayStart"); //查询的起始条数
        System.out.println("iDisplayStart" + iDisplayStart);
        String iDisplayLength = request.getParameter("iDisplayLength");  //每页显示的条数
        System.out.println("iDisplayLength" + iDisplayLength);

        String returnJson = QueryReceiveLog.query(iDisplayStart, iDisplayLength, id, startTime, endTime, MessageType, MessageNo);

        try (PrintWriter out = response.getWriter()) {
            /* TODO output your page here. You may use following sample code. */
            out.println(returnJson);
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
